

<?php

$path = "upload/";




$valid_formats = array("jpg", "png", "gif", "bmp", "JPG", "jpeg", "PNG", "GIF", "BMP", "JPEG");
if (isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") {
    $name = $_FILES['logo1']['name'];

    if (strlen($name)) {
        list($txt, $ext) = explode(".", $name);
        if (in_array($ext, $valid_formats)) {

            $actual_image_name = time() . substr(str_replace(" ", "_", $txt), 5) . "." . $ext;
            $tmp = $_FILES['logo1']['tmp_name'];
            if (move_uploaded_file($tmp, $path . $actual_image_name)) {

                echo "<img src='" . $path . $actual_image_name . "' class='preview' />
                    <input type='hidden' name='logo' value='" . $path . $actual_image_name . "' />";
            }
            else
                echo "Erreur de téléchargement du fichier";
        }
        else
            echo "Format de fichier invalide..";
    }

    else
        echo "Veuillez choisir une image..!";

    
}
exit();
?>